home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / graphic / cheetah.zip / UGETZ4P.C < prev    next >
C/C++ Source or Header  |  1992-08-21  |  4KB  |  135 lines

  1. /* -- Not realized --  */
  2. /* ugetz4p.c
  3.  *
  4.  * UNCHAINED mode version.
  5.  * NOTE that in this mode BPERROW is a permanent constant, and always equal to
  6.  * BPERROW_CHAINED.
  7.  *
  8.  * Description:
  9.  *      Get screen image and encode it to Z4Planes format.
  10.  *
  11.  * Function list:
  12.  *      UgetZ4Planes().
  13.  *
  14.  * Portability: BORLANDC
  15.  *                                      (c) erdy 1992
  16.  * $Header: $
  17.  */
  18. #pragma inline
  19. #include <limits.h>
  20. #include <alloc.h>       /* farcoreleft() */
  21. #include "far.h"
  22. #include "vgaprefx.h"
  23. #include "vgadrv.h"
  24. #include "screen.h"
  25. #include "mxcpy.h"
  26.  
  27.  
  28. Image far *UgetZ4Planes(unsigned int x, unsigned int y,
  29.                         unsigned int nc, unsigned int nr,
  30.                         int backcolor)
  31. {
  32.         return(0);
  33. #if 0
  34.         char far *p;
  35.         Image far *ip;
  36.     auto unsigned int sz;
  37.     auto unsigned long coreleft;
  38.         auto unsigned int ncols;
  39.         auto unsigned int n;
  40.         auto unsigned int pl;
  41.         auto unsigned int row, col;
  42.         auto unsigned char lastoff;
  43.         auto union bw {
  44.                 char b[2];
  45.                 int  w;
  46.         } bc;
  47.  
  48.         bc.w = backcolor;
  49.  
  50.         coreleft = (unsigned long)nc * nr;
  51.         coreleft += sizeof(Image);
  52.         if (coreleft > UINT_MAX)
  53.         sz = UINT_MAX;
  54.     else
  55.         sz = coreleft;
  56.         if ((coreleft = farcoreleft()/2) > UINT_MAX)
  57.                 coreleft = UINT_MAX;
  58.         if (sz > coreleft)
  59.                 coreleft = sz;
  60.         coreleft -= 6;
  61. If_Overflow:
  62.         if ((p = getmem(sz)) == NULL) {
  63. Abort:
  64.                 scerror = ER_OUTOFMEM;
  65.         return(NULL);
  66.         }
  67.         sz -= 6;
  68.  
  69.         y = VIDEO_ADDRESS(x, y);        /* Will keep video RAM offset */
  70.         x &= 3;                         /* Will keep starting offset */
  71.         /* nc will keep number of completed 4s, plus 1st one (maybe incompleted) */
  72.         n = (lastoff = x + nc)/BITPLANES;
  73.     lastoff &= 3;                   /* Offset of last pixel in group-of-4 */
  74.  
  75.     _A_selectMap();         /* Point gate to Select Map register */
  76.  
  77.     asm cld;
  78.     asm push ds;
  79.  
  80.     asm les di, p;                  /* Load data address */
  81.         _AX = Scdraw_seg;                /* Load video address */
  82.     _DS = _AX;
  83.  
  84.     asm xor dx, dx;         /* Clear the used space counter */
  85.     for (pl = 1; pl <= BITPLANES; pl++) {
  86.         asm push dx;            /* Save space counter */
  87.  
  88.                 ncols = n;
  89.         _AL = pl + x;           /* To reach proper plane's order */
  90.         if (_AL > BITPLANES) {    /* Wrap across 4-group */
  91.             _AL -= BITPLANES;
  92.             y++;            /* Increment VRAM offset */
  93.             ncols--;        /* Not present in the 1st group-of-4 */
  94.         }
  95.         if (_AL <= lastoff)
  96.             ncols++;        /* Present in the last group-of-4 */
  97.  
  98.         _D_selectMap(_AL);      /* Select correct plane of {1,2,3,4} */
  99.         asm pop dx;             /* Restore counter */
  100.  
  101.         _SI = y;                /* Set starting video offset */
  102.  
  103.         for (row = 0; row < nr; row++) {
  104.  
  105.             asm pop si;
  106.             asm add si, BPERROW_UNCHAINED;    /* Advance to next row */
  107.         }
  108.     }
  109.     sz = _DX;
  110.     asm pop ds;
  111.  
  112.     if ((ip = (Image far *)getmem((unsigned long)sz + sizeof(Image))) == NULL) {
  113.                 retmem(p);
  114.         scerror = ER_OUTOFMEM;
  115.         return(NULL);
  116.     }
  117.  
  118.     /* Copy data */
  119.     _offset(ip) = sizeof(Image);  /* _offset(ip) was equal to 0 ! */
  120.     _mxcpy(p, ip, sz);
  121.         retmem(p);
  122.  
  123.         /* Establish image */
  124.         _offset(ip) = 0;
  125.         ip->d.size = sz;
  126.         ip->d.twidth = ip->d.width = nc;
  127.         ip->d.theight = ip->d.height = nr;
  128.         ip->d.ncolormaps = ip->d.x = ip->d.y = 0;
  129.         ip->d.format = Z4Planes;
  130.         p = (char far *)ip + sizeof(Image);
  131.         _farnormal(p);          /* Offset p must be 0 ! */
  132.     ip->d.data = p;
  133.     return(ip);
  134. #endif
  135. }